/*
 *
 *  Copyright (C) 2012-2024
 *  All rights reserved, Designed By 杭州连线客信息技术有限公司
 *  注意：
 *  本软件为杭州连线客信息技术有限公司开发研制，未经购买不得使用
 *  购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 *  一经发现盗用、分享等行为，将追究法律责任，后果自负
 *
 */

package com.lxk.listener.oms;

import cn.hutool.core.bean.BeanUtil;
import com.lxk.event.oms.OrderOptionLogEvent;
import com.lxk.service.oms.api.OrderOptionLogServiceApi;
import com.lxk.service.oms.dto.OrderOptionLogDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.utils.ValidationUtils;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;


/**
 * 监听定时任务事件
 *
 * @Author huahua
 * @Date 2024/08/30
 * @Version 1.0
 */
@Slf4j
@Component
@EnableAsync
@AllArgsConstructor
public class OrderOptionLogEventListener {


    private final OrderOptionLogServiceApi orderOptionLogServiceApi;

    /**
     * 订单操作事件
     *
     * @param event
     */
    @EventListener(OrderOptionLogEvent.class)
    public void orderOptionListener(OrderOptionLogEvent event) {
        ValidationUtils.validate(event);
        OrderOptionLogDto logDto = BeanUtil.copyProperties(event, OrderOptionLogDto.class);
        logDto.setOrderLogEnums(event.getOrderLogEnums().getCode());
        log.info("监听事件:OrderOptionLogEvent:{}", event);
        orderOptionLogServiceApi.insertLog(logDto);
    }

}
